class Solution {
public:
    int findMinArrowShots(vector<vector<int>>& points) {
        if (points.size() <= 1) return points.size();

        // 按照区间的左边界升序排列
        sort(points.begin(), points.end(), [](const vector<int>& u, const vector<int>& v) {
            return u[0] < v[0];
        });

        int res = 1;
        // 将第一个区间设置为可射区间
        vector<int> range = {points[0][0], points[0][1]};

        for (int i = 1; i < points.size(); i++) {
            vector<int> curr = points[i];
            if (curr[0] <= range[1]) {
                range[0] = max(range[0], curr[0]);
                range[1] = min(range[1], curr[1]);
            } else {
                res++;
                range[0] = curr[0];
                range[1] = curr[1];
            }
        }

        return res;
    }

    int findMinArrowShots(vector<vector<int>>& points) {
        if (points.size() <= 1) return points.size();

        // 按照区间的右边界升序排列
        sort(points.begin(), points.end(), [](const vector<int>& u, const vector<int>& v) {
            return u[1] < v[1];
        });

        int res = 1;
        int pos = points[0][1];
        for (int i = 1; i < points.size(); i++) {
            if (points[i][0] > pos) {
                res++;
                pos = points[i][1];
            }
        }

        return res;
    }

    int findMinArrowShots(vector<vector<int>>& points) {
        if (points.size() <= 1) return points.size();

        // 按照区间的右边界升序排列
        sort(points.begin(), points.end(), [](const vector<int>& u, const vector<int>& v) {
            return u[1] < v[1];
        });

        int res = 1;
        int pos = points[0][1];
        for (int i = 1; i < points.size(); i++) {
            if (points[i][0] > pos) {
                res++;
                pos = points[i][1];
            }
        }

        return res;
    }
};